package vue;

import java.awt.BorderLayout;

import javax.swing.GroupLayout;
import javax.swing.JPanel;
import javax.swing.JButton;

import memory.Memory;

import controleur.CExit;
import controleur.CGetHelp;

@SuppressWarnings("serial")
public class VMenubar extends JPanel {
	
	 protected JButton goBack, help; //Composants
	 protected VRootWindow rootWin; //Reference sur la fenetre principale (utile pour creer un bouton de retour a l'accueil)
	 
	 public VMenubar(VRootWindow rw) {
		 
		 rootWin = rw;
		 setBackground(Memory.BG_COLOR.darker());
		 
		 /*Configuration des boutons*/
		 help = new JButton("Aide");
		 help.addMouseListener(new CGetHelp(rootWin));
		 
		 goBack = new JButton("Quitter");
		 goBack.addMouseListener(new CExit(rootWin));
		 
		 /*Encapsulation dans un JPanel pour l'alignement gauche - droite (BorderLayout)*/
		 JPanel content = new JPanel();
		 content.setLayout(new BorderLayout());
		 content.add(help, BorderLayout.WEST);
		 content.add(goBack, BorderLayout.EAST);
		 content.setBackground(Memory.BG_COLOR.darker());
		 
		 /*Création de marges autour du JPanel content avec GroupLayer*/
		 GroupLayout layout = new GroupLayout(this);
		 setLayout(layout);
		 layout.setAutoCreateContainerGaps(true);
		 layout.setHorizontalGroup(
				 layout.createSequentialGroup().addComponent(content));
		 layout.setVerticalGroup(
				 layout.createParallelGroup().addComponent(content));
	 }
	 
	 public void setRetour() {
		 goBack.setText("Retour accueil");
	 }
	 
	 public void setQuitter() {
		 goBack.setText("Quitter");
	 }
	 
}
